﻿/*****************************************************************************************************
* Gaia Framework for Adobe Flash ©2007-2009
* Author: Steven Sacks
*
* blog: http://www.stevensacks.net/
* forum: http://www.gaiaflashframework.com/forum/
* wiki: http://www.gaiaflashframework.com/wiki/
* 
* By using the Gaia Framework, you agree to keep the above contact information in the source code.
* 
* Gaia Framework for Adobe Flash is released under the MIT License:
* http://www.opensource.org/licenses/mit-license 
*****************************************************************************************************/

package
{
	import com.gaiaframework.core.GaiaMain;
	import flash.display.Sprite;
	import utils.ShapeUtil;
	import utils.SpriteUtil;
	
	import flash.display.StageScaleMode;
	import flash.display.StageAlign;
	import flash.events.Event;
	
	public class Main extends GaiaMain
	{	
		public var background:Sprite;
		public function Main()
		{
			super();
			var rootDirectory:String = stage.loaderInfo.parameters.base || "";
			siteXML = rootDirectory+"xml/site.xml";
		}
		override protected function onAddedToStage(event:Event):void
		{
			super.onAddedToStage(event);
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			addBg();
			_onResize();
			stage.addEventListener(Event.RESIZE, _onResize);
		}
		
		private function _onResize(e:Event=null):void 
		{
			if (background)
			{
				background.x = background.y = 0;
				background.width = stage.stageWidth;
				background.height = stage.stageHeight;
			}
		}
		
		private function addBg():void 
		{
			background  = ShapeUtil.getSprite(100, 100, 0x000000, 1);
			addChild(background);
		}
		
	}
}
